<template>
    <div>
     <a-drawer
    :width="700"
    title="报名详情"
    placement="right"
    :visible="visible"
    @close="onClose">
     <a-card :bordered="false" title="个人信息">
        <detail-list :col="1">
            <detail-list-item term="任务报价">{{detail.price}}</detail-list-item>
            <detail-list-item term="备注">{{detail.description}}</detail-list-item>
            <detail-list-item term="图片信息">
                <viewer :images="detail.img">
                    <img v-for="item in detail.img" :src="item" :key="item" style="width: 100px;display: inline-block;margin: 4px;cursor: pointer;">
                </viewer>
            </detail-list-item>
        </detail-list>
    </a-card>
    <a-card :bordered="false" title="工作经验">
        <detail-list :col="1">
            <detail-list-item term="行业">{{detail.industry}}</detail-list-item>
            <detail-list-item term="从业时间">{{detail.engageTime}}</detail-list-item>
            <detail-list-item term="项目经验">{{detail.projectExperience}}</detail-list-item>
            <detail-list-item term="从业资格证">
                <img v-if="detail.engageCertificate && detail.engageCertificate.length >= 1" style="width: 100px;display: inline-block;margin: 4px;" v-for="item in detail.engageCertificate" :key="item" :src="item">
            </detail-list-item>
        </detail-list>
    </a-card>
    <a-card :bordered="false" title="教育经历">
        <detail-list :col="1">
            <detail-list-item term="学历">{{detail.degree}}</detail-list-item>
            <detail-list-item term="学校名称">{{detail.schoolName}}</detail-list-item>
            <detail-list-item term="毕业时间">{{detail.graduateTime}}</detail-list-item>
        </detail-list>
    </a-card>
    <div class="footer" v-if="taskState === 1" :style="{ padding: '10px 16px',borderTop: '1px solid #e8e8e8',background: '#fff',position: 'fixed',bottom: 0,right: 0,width: '700px',textAlign: 'right'}">
        <a-button type="danger" :style="{ marginRight: '8px' }" @click="onError">不通过</a-button>
        <a-button type="primary" :style="{ marginRight: '10px' }" @click="onOK">通过</a-button>
    </div>
  </a-drawer>
  <a-drawer
        :visible="innerVisible"
        title="不通过理由"
        width="700"
        placement="left"
        :closable="false">
        <a-textarea v-model:value="reason" :rows="8" />
        <div class="footer" :style="{ padding: '10px 16px',borderTop: '1px solid #e8e8e8',background: '#fff',position: 'fixed',bottom: 0,left:0,width: '700px',textAlign: 'right'}">
            <a-button :style="{ marginRight: '8px' }" @click="innerVisible=false">取消</a-button>
            <a-button type="primary" :style="{ marginRight: '10px' }" @click="onInerOK">提交</a-button>
        </div>
    </a-drawer>
</div>
</template>

<script>
import { 
    allGetEnrollUser,
    allApplyEnrollUserInfo
} from '@/api/manage/sttle'
import DetailList from '@/components/tools/DetailList'
const DetailListItem = DetailList.Item
export default {
  name: 'taskEnroll',
  components: {
        DetailList,
        DetailListItem
    },
  data () {
    return {
       visible:false,
       innerVisible:false,
       reason:'',
       importId:'',
       taskState:'',
       detail:{
           price:'',
           description:'',
           img:[],
           industry:'',
           engageTime:'',
           projectExperience:'',
           engageCertificate:'',
           degree:'',
           schoolName:'',
           graduateTime:''
       }
    }
  },
  created () {
  },
  methods: {
    async add(item){
        this.importId = item.importId;
        this.taskState = item.operateStatus;
        const {code,data} = await allGetEnrollUser(item.importId);
        if(code === '1'){
            if(data && data != null){
                Object.assign(this.detail,data);
                this.detail.img = data.img ? data.img.split(','):'';
                for(var key in data.workExperience){
                    if(key === 'engageCertificate'){
                        this.detail[key] = data.workExperience[key] ? data.workExperience[key].split(','):'';
                    }else{
                        this.detail[key] = data.workExperience[key];
                    }
                }
                for(var key in data.education){
                    this.detail[key] = data.education[key];
                }
                this.visible = true;
            }else{
                this.$message.error('没有报名信息');
            }
        }
    },
    onError(){
        this.reason = '';
        this.innerVisible = true;
    },
    async onInerOK(){
        if(!this.reason){
            return this.$message.error('请填写理由！');
        }
        let params = {
            importId:this.importId,
            reason:this.reason,
            operateStatus:3
        }
        const {code} = await allApplyEnrollUserInfo(params);
        if(code === '1'){
            this.$message.success('操作成功');
            this.innerVisible = false;
            this.visible = false;
            this.$emit("on-ok");
        }
    },
    async onOK(){
        let params = {
            importId:this.importId,
            operateStatus:2
        }
        const {code} = await allApplyEnrollUserInfo(params);
        if(code === '1'){
            this.$message.success('操作成功');
            this.innerVisible = false;
            this.visible = false;
            this.$emit("on-ok");
        }
    },
    onClose(){
        this.visible = false;
    }
  }
}
</script>
